//
//  LBButton.m
//  Cunli
//
//  Created by ZhanyaaLi on 15/12/4.
//  Copyright © 2015年 lilubin. All rights reserved.
//

#import "LBButton.h"
#import "LBBtnModel.h"
#import "UIView+CYExtenssion.h"

@implementation LBButton

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.titleLabel.textAlignment = NSTextAlignmentCenter;
        self.titleLabel.font = [UIFont systemFontOfSize:12];
        [self setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    }
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
//    self.imageView.width = self.width * 0.5;
    self.imageView.width = 60;
    self.imageView.height = self.imageView.width;
    self.imageView.y = self.height * 0.1;
    self.imageView.centerX = self.width * 0.5;
    
    self.titleLabel.width = self.width;
    self.titleLabel.y = CGRectGetMaxY(self.imageView.frame);
    self.titleLabel.x = 0;
    self.titleLabel.height = self.height - self.titleLabel.y;
}

- (void)setBtnModel:(LBBtnModel *)btnModel
{
    _btnModel = btnModel;
    [self setTitle:btnModel.labelTitle forState:UIControlStateNormal];
    [self setImage:[UIImage imageNamed:[btnModel imgName]] forState:UIControlStateNormal];
}

@end
